package com.hngates.architecture.service.impl;

import com.hngates.architecture.domain.ArcProjectBuilderRel;
import com.hngates.architecture.mapper.ArcProjectBuilderRelMapper;
import com.hngates.architecture.service.IArcProjectBuilderRelService;
import com.hngates.common.core.text.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 工地与建设单位对应关系Service业务层处理
 *
 * @author jwhe
 * @date 2022-07-04
 */
@Service
public class ArcProjectBuilderRelServiceImpl implements IArcProjectBuilderRelService {
    @Autowired
    private ArcProjectBuilderRelMapper arcProjectBuilderRelMapper;

    /**
     * 查询工地与建设单位对应关系
     *
     * @param id 工地与建设单位对应关系主键
     * @return 工地与建设单位对应关系
     */
    @Override
    public ArcProjectBuilderRel selectArcProjectBuilderRelById(Long id) {
        return arcProjectBuilderRelMapper.selectArcProjectBuilderRelById(id);
    }

    /**
     * 查询工地与建设单位对应关系列表
     *
     * @param arcProjectBuilderRel 工地与建设单位对应关系
     * @return 工地与建设单位对应关系
     */
    @Override
    public List<ArcProjectBuilderRel> selectArcProjectBuilderRelList(ArcProjectBuilderRel arcProjectBuilderRel) {
        return arcProjectBuilderRelMapper.selectArcProjectBuilderRelList(arcProjectBuilderRel);
    }

    /**
     * 新增工地与建设单位对应关系
     *
     * @param arcProjectBuilderRel 工地与建设单位对应关系
     * @return 结果
     */
    @Override
    public int insertArcProjectBuilderRel(ArcProjectBuilderRel arcProjectBuilderRel) {
        return arcProjectBuilderRelMapper.insertArcProjectBuilderRel(arcProjectBuilderRel);
    }

    /**
     * 修改工地与建设单位对应关系
     *
     * @param arcProjectBuilderRel 工地与建设单位对应关系
     * @return 结果
     */
    @Override
    public int updateArcProjectBuilderRel(ArcProjectBuilderRel arcProjectBuilderRel) {
        return arcProjectBuilderRelMapper.updateArcProjectBuilderRel(arcProjectBuilderRel);
    }

    /**
     * 批量删除工地与建设单位对应关系
     *
     * @param ids 需要删除的工地与建设单位对应关系主键
     * @return 结果
     */
    @Override
    public int deleteArcProjectBuilderRelByIds(String ids) {
        return arcProjectBuilderRelMapper.deleteArcProjectBuilderRelByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除工地与建设单位对应关系信息
     *
     * @param id 工地与建设单位对应关系主键
     * @return 结果
     */
    @Override
    public int deleteArcProjectBuilderRelById(Long id) {
        return arcProjectBuilderRelMapper.deleteArcProjectBuilderRelById(id);
    }

    @Override
    public boolean selectArcProjectBuilderRelById(Long projectId, Long builderCompanyId) {
        int n = arcProjectBuilderRelMapper.selectArcProjectBuilderRelByIds(projectId, builderCompanyId);
        return n > 0;
    }
}
